
package test3;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;


public class Charge {
    public long checkTime(String time1, String time2) throws ParseException {
        long nm = 1000 * 60;
        long minDiff;
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        Date t1 = format.parse(time1);
        Date t2 = format.parse(time2);
        Calendar cal1 = Calendar.getInstance();
        cal1.setTime(t1);
        Calendar cal2 = Calendar.getInstance();
        cal2.setTime(t2);
        long timeDiff = cal2.getTime().getTime() - cal1.getTime().getTime();

        if(timeDiff>=0 && timeDiff/1000<60 || timeDiff%nm>0)
            minDiff = timeDiff/nm+1;
        else
            minDiff = timeDiff/nm;

        if(cal1.get(Calendar.MONTH) == Calendar.OCTOBER && cal1.get(Calendar.DATE) >= 25 && cal1.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
//               时间为负
            if(cal1.get(Calendar.HOUR_OF_DAY)==2 && cal2.get(Calendar.HOUR_OF_DAY)==2 && cal2.get(Calendar.HOUR_OF_DAY)<3 && cal2.get(Calendar.MINUTE)<=cal1.get(Calendar.MINUTE))
                minDiff+=60;
            else if(cal1.get(Calendar.HOUR_OF_DAY)<2 && cal1.get(Calendar.HOUR_OF_DAY)>=2) {
                minDiff+=60;
            }
            else {

            }

        }
        else{
            if(cal2.get(Calendar.MONTH) == Calendar.OCTOBER && cal2.get(Calendar.DATE) >= 25 && cal2.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
                if(cal2.get(Calendar.HOUR_OF_DAY)>=2)
                    minDiff +=60;
            }
            else {
                if((cal1.get(Calendar.MONTH) == Calendar.MARCH && cal1.get(Calendar.DATE) >= 25 && cal1.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)){
                    if(cal1.get(Calendar.HOUR_OF_DAY)<2 && cal2.get(Calendar.HOUR_OF_DAY)>=3)
                        minDiff -=60;
                }
                else{
                    if((cal2.get(Calendar.MONTH) == Calendar.MARCH && cal2.get(Calendar.DATE) >= 25 && cal2.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)){

                        if(cal2.get(Calendar.HOUR_OF_DAY)>=3 )
                            minDiff -= 60;
                    }
                }
            }
        }
        return minDiff;

    }
    public double CountMoney(long time){
        double money = 0;
        if(time <= 0|| time >1800){
            money = -1.0;
        }
        else if(time > 0 && time <=20){
            money = time*0.05;
        }
        else
            money = 1+(time - 20)*0.1;
        return money;
    }

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String cal11 = br.readLine();
            String cal22 = br.readLine();
            test3.Charge c1 = new test3.Charge();
            SimpleDateFormat simplefomat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss E");

            long minDiff1 = c1.checkTime(cal11,cal22);
            double money = c1.CountMoney(minDiff1);
            System.out.println(money);
        } catch (IOException | ParseException e) {
            e.printStackTrace();
        }
    }

}
